<include file="Public/header"/>
<body class="body-bg">
<div class="park-header">
    <div class="park-header__title"><if condition="$type_id eq 1">新品速递<else />热卖推荐</if></div>
    <div class="park-header__left park-back">
        <i class="iconfont icon-fanhui"></i>
    </div>
</div>
<div class="container">
    <div class="park__goods" style="margin-top: 0.2rem;">
        <ul id="goods_list"></ul>
    </div>
</div>
<div class="park-mask"></div>
<script src="__ROOT__/Public/Home/layer/layer.js"></script>
<script>
    $(function () {
        var options = {
            type: 'get', // default 'get'
            dataType: 'html' // default 'json'
        };
        var url = '/Home/Index/new_goods/';
        var type_id = '{$type_id}';
        var params = {'act':'ajax','type':type_id};
        PARK.dropLoad(PARK.dropAjax(options, url, params, function (data) {
            var data = JSON.parse(data);
            var html = '';
            for (var i = 0; i < data.result.length; i++) {
                html += '<li>';
                html += '    <div onclick="goods_detail(' + data['result'][i]['id'] + ',' + data['result'][i]['store_id'] + ');" class="park-goods__pic" style="background-image: url(' + data['result'][i]['thumb'] + ')"></div>';
                html += '    <div onclick="goods_detail(' + data['result'][i]['id'] + ',' + data['result'][i]['store_id'] + ');" class="park-goods__info">';
                html += '        <p class="name">' + data['result'][i]['goods_name'] + '</p>';
                html += '        <p class="desc">' + data['result'][i]['store_name'] + '</p>';
                html += '        <p class="spec">' + data['result'][i]['spec_name'] + '&nbsp;</p>';
                html += '        <p class="price-line">';
                html += '            <span class="price">￥<em>' + data['result'][i]['left_price'] + '</em>' + data['result'][i]['right_price'] + '</span>';
                html += '        </p>';
                html += '    </div>';
                html += '    <div class="park-goods__pos">';
                html += '        <div class="cart" onclick="sum_form('+data['result'][i]['goods_id']+','+data['result'][i]['store_id']+','+data['result'][i]['spec_id']+');">';
                html += '            <i class="iconfont icon-cart"></i>';
                html += '        </div>';
                html += '    </div>';
                html += '</li>';
            }
            $('#goods_list').append(html);
            if(data.is_page==1){
                PARK.unDropLoad();
            }
        }));
    });
	function sum_form(goods_id,store_id,spec_id){
        if(!spec_id){
            return false;
        }
        var goods_number = 1;
        $.post('/Home/Cart/add_cart/',{goods_id:goods_id,store_id:store_id,spec_id:spec_id,goods_number:goods_number},function(data){
            if(data.code==200){
                $('#cart_number').html(data.result);
            }
            layer.open({
                content:data.msg
                ,skin: 'msg'
                ,time: 2 //2秒后自动关闭
            });
        },'json');
    }
</script>
</body>
</html>